package vn.sunnet.backviet01.game.coloa.util.mypool;

import org.anddev.andengine.opengl.texture.region.TextureRegion;
import org.anddev.andengine.util.pool.GenericPool;

import vn.sunnet.backviet01.game.coloa.human.enemy.EnemyArrow;

public class ArrowOfRangePool extends GenericPool<EnemyArrow>{
private final TextureRegion mTextureRegion;
	
	public ArrowOfRangePool(TextureRegion pTextureRegion) {
		if (pTextureRegion == null) {
			throw new IllegalArgumentException("The texture region must not be NULL");
		} 
		mTextureRegion = pTextureRegion;
	}
	@Override
	protected EnemyArrow onAllocatePoolItem() {
		// TODO Auto-generated method stub
		return new EnemyArrow(0, 0, 0, mTextureRegion.deepCopy());
	}

	protected void onHandleRecycleItem(final EnemyArrow arrowOfRange) {
		arrowOfRange.setIgnoreUpdate(true);
		arrowOfRange.clearEntityModifiers();
		arrowOfRange.clearUpdateHandlers();
		arrowOfRange.setVisible(false);
		arrowOfRange.detachSelf();
		arrowOfRange.reset();
	}
	
}
